from flask_admin.form import ImageUploadField

from poker_bot.admin_panel.app.constants import reviews_folder
from poker_bot.admin_panel.app.views import MyBaseModelView


class ReviewModelView(MyBaseModelView):
    column_list = (
        "review_text",
        "created_at",
    )

    form_excluded_columns = ("updated_at",)

    column_labels = {
        "review_text": "Текст отзыва",
        "image_path": "Фото отзыва",
        "created_at": "Дата создания",
    }

    form_extra_fields = {
        "image_path": ImageUploadField(
            "Фото отзыва",
            base_path=reviews_folder,
            allow_overwrite=True,
            allowed_extensions=["png", "jpg"],
            endpoint="media_bp.reviews",
        )
    }
